package com.jic.order.mapper;

import com.alibaba.fastjson.JSONObject;
import com.jic.common.base.vo.RestResult;
import com.jic.order.entity.Order;
import com.jic.order.manage.response.OrderResponse;
import com.jic.order.model.domain.OrderGoodsListModel;
import com.jic.order.model.entity.MOrderBale;
import com.jic.order.request.DistributorOrderRequest;
import com.jic.order.request.OrderQueryPage;
import com.jic.order.request.OrderStatisticsRequest;
import com.jic.order.response.OrderGoodsInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 订单主表
 *
 * @author : yinhaijun
 * @version : v1.0.0
 * @email :
 * @since : 2020-01-13 06:17:06
 *
 */
@Mapper
public interface OrderMapper {

	long insert(Order order);

	long delete(Long id);

	long update(Order order);

	Order queryByPrimaryKey(@Param("orderNo") String orderNo, @Param("parentOrderNo") String parentOrderNo);

	Order queryByOrderNo(String orderNo);

	List<Order> query(Order order);

	List<Order> queryPage(@Param("startIndex") int startIndex, @Param("order") OrderQueryPage orderQueryPage);
    List<Order> queryPageOrder(@Param("order") OrderQueryPage orderQueryPage);

	long queryPageCount(@Param("order") OrderQueryPage orderQueryPage);

	//联动更新订单状态
	long coupUpdateOrderStatus(String orderNo);

	//联动更新父订单状态
	long coupUpdateParentOrderStatus(String orderNo);

	Order queryByParentOrderNo(String orderNo);

	List<OrderGoodsListModel> queryOrderGoods(@Param("orderNo") String orderNo);

	List<OrderGoodsInfo> queryDistributionOrder(DistributorOrderRequest distributorOrderRequest);

    RestResult<MOrderBale> getParcel(@Param("orderNo") String orderNo);
	//确认收货
	boolean confirmReceipt(@Param("jdOrderId") String jdOrderId);

	//取消未确认订单
	boolean cancelUnconfirmedOrders(@Param("jdOrderId") String jdOrderId);

	//根据京东订单号获取主键id
	long getIdByJdOrderId(@Param("jdOrderId") String jdOrderId);

	//根据订单id获父订单ID
	long getParentIdByOrderId(@Param("id") long id);

	List<Map<String, Object>> queryFirstPaymentCount(OrderStatisticsRequest request);

	List<Map<String, Object>> queryOrderCount(OrderStatisticsRequest request);

	List<Map<String, Object>> queryOrderGmv(OrderStatisticsRequest request);
	List<JSONObject> queryMOrderByDate(JSONObject jsonObject);

	List<JSONObject> queryOrderByOrderNo(@Param("parent_order_no") String parent_order_no);

	Integer updateByOrderNo(JSONObject jsonObject);

	Integer insertOrderSettlement(JSONObject jsonObject);

	List<JSONObject> querySubmitOrderUserLeft(OrderStatisticsRequest request);

	Integer updateOrderSettlement(JSONObject jsonObject);

	Integer insertScoreRecord(JSONObject ret);

	Integer updateScoreRecord(JSONObject ret);

    List<OrderResponse> queryBycommodityCode(@Param("commodityCode") String commodityCode,@Param("settStartTime")  Date settStartTime, @Param("settEndTime") Date settEndTime);

    List<OrderResponse> queryBycommodityCodeNumber(@Param("commodityCode")String commodityCode, @Param("settStartTime")Date settStartTime,@Param("settEndTime") Date settEndTime);
}
